package com.example.yang.yixin.Adapter;


import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.support.annotation.NonNull;
import android.support.design.widget.Snackbar;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.example.yang.yixin.Activity.BankeActivity;
import com.example.yang.yixin.Activity.LoginActivity;
import com.example.yang.yixin.Activity.MeActivity;
import com.example.yang.yixin.Activity.SignInActivity;
import com.example.yang.yixin.R;
import com.example.yang.yixin.Utils.Class_info;
import com.example.yang.yixin.Utils.ScreenLock;
import com.example.yang.yixin.Utils.Sign_info;

import org.w3c.dom.Text;

import java.util.ArrayList;
import java.util.List;

public class SignAdapter extends RecyclerView.Adapter<SignAdapter.ViewHolder> {
    private List<Sign_info> signinfoList;





    public SignAdapter(List<Sign_info> signinfoList) {
        this.signinfoList = signinfoList;

    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) {
        View view=LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.sign_info,viewGroup,false);
        final ViewHolder holder=new ViewHolder(view);
        return holder;
    }


    public void onBindViewHolder(ViewHolder viewHolder, final int position) {
        Sign_info sign_infomation=signinfoList.get(position);
        viewHolder.username.setText("学号:"+sign_infomation.getusername());
        viewHolder.name.setText("姓名:"+sign_infomation.getname());
        viewHolder.queqing.setText("缺勤:"+(Integer.parseInt(sign_infomation.getMosttime())-Integer.parseInt(sign_infomation.gettime()))+"次");
        viewHolder.chuqin.setText("出勤:"+sign_infomation.gettime()+"次");
        viewHolder.itemView.setTag(position);



    }


    @Override
    public int getItemCount() {
        return signinfoList.size();
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        TextView username;
        TextView name;
        TextView queqing;
        TextView chuqin;
        View Sign_info;

        public ViewHolder(View view){
            super(view);
            Sign_info=view;
            username=(TextView) view.findViewById(R.id.xuehao);
            name=(TextView) view.findViewById(R.id.name);
            queqing=(TextView)view.findViewById(R.id.queqing);
            chuqin=(TextView)view.findViewById(R.id.chuqin);
        }



    }
}
